<template>
    <div class="leftList comm-list" v-infinite-scroll="load">
        <div class="item-box" @click="clickItem(index)" :class="listI == index ? 'acitve' : ''"
            v-for="(item, index) in listData" :key="index">
            <div>
                <div v-for="(row, i) in templates" :key="i">
                    <p :class="row.class" v-if="row.type == 'init'">{{ item[row.key] }}</p>
                    <slot :row="item" v-if="row.type == 'slot'" :name="row.key"></slot>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: ['templates', 'listData'],
    data() {
        return {
            listI: 0,
        }
    },
    created() {

    },
    methods: {
        clickItem(index) {
            this.listI = index
            this.$emit("clickItem", index)
        },
        load() {
            this.$emit("loadFun")
        },
    }
}
</script>

<style lang="scss" scoped>
div {
    box-sizing: border-box;
}

.leftList {
    font-size: 14px;
    margin-top: 10px;
    // background: red;
    height: calc(100vh - 40px - 15px - 10px - 40px - 10px);
    overflow-y: auto;

    .item-box {
        width: 100%;
        padding: 10px;
        border-radius: 5px;
        background: #fbfbfb;
        margin-bottom: 6px;
        position: relative;
        cursor: pointer;

        .ps {
            color: #999999;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        &:hover {
            background: #fdf6f6;
        }

    }

    .acitve {
        background: #3e8af9;
        color: #fff;

        .ps {
            color: #DDDDDD;
        }

        &:hover {
            background: #3e8af9;
        }
    }

    .num_od {
        border-top: 1px solid #ede7e7;
        height: 40px;
        line-height: 40px;
        margin-top: 6px;
    }
}
</style>